<?php 
namespace app\admin\validate;
use app\admin\code\AdminCode;
use app\admin\code\AuthCode;
use app\admin\code\BaseCode;
use app\admin\model\BaseModel;
use think\Validate;

class AdValidate extends BaseValidate
{
    protected $_rule = [
        'id'       =>  'require',
        'name'     =>  'require',
        'sort'     =>  'number',
        'img'      =>  'require',
        'is_use'   =>  'in:0,1',
        'url'      =>  'url|require',
    ];
    protected $_field = [
        'id'=>'图片',
        'name'=>'别名',
        'sort'=>'排序',
        'img'=>'广告图',
        'is_use'=>'是否启用',
        'url'=>'链接',
    ];
    protected $_message = [
        'id.require' => BaseCode::PARAM_CANT_EMPTY,
        'name.require' => BaseCode::PARAM_CANT_EMPTY,
        'sort.number' => BaseCode::PARAM_MUST_NUMBER,
        'img.require' => BaseCode::PARAM_CANT_EMPTY,
        'is_use.in' => BaseCode::PARAM_MUST_IN,
        'url.require' => BaseCode::PARAM_CANT_EMPTY,
        'url.url' => BaseCode::PARAM_MUST_BE_URL,
    ];
    protected $_scene = [
        'update' => ['id','name','img','is_use','sort','url'],
        'add'    => ['name','img','is_use','sort','url'],
        'del' => ['id'],
    ];
}


